package com.ysqcould.web.controller.content;


import com.ysqcould.common.annotation.Log;
import com.ysqcould.common.core.controller.BaseController;
import com.ysqcould.common.core.domain.AjaxResult;
import com.ysqcould.common.core.page.TableDataInfo;
import com.ysqcould.common.enums.BusinessType;
import com.ysqcould.common.utils.poi.ExcelUtil;
import com.ysqcould.content.domain.EditRecord;
import com.ysqcould.content.domain.vo.RecordVo;
import com.ysqcould.content.service.IEditRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 个人修改企业记录Controller
 * 
 * @author ruoyi
 * @date 2022-06-30
 */
@RestController
@RequestMapping("/content/record")
public class EditRecordController extends BaseController
{
    @Autowired
    private IEditRecordService editRecordService;

    /**
     * 查询个人修改企业记录列表
     */
    @PreAuthorize("@ss.hasPermi('content:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(EditRecord editRecord)
    {
        startPage();
        List<RecordVo> list = editRecordService.selectEditRecordList(editRecord);
        return getDataTable(list);
    }

    /**
     * 导出个人修改企业记录列表
     */
  /*  @PreAuthorize("@ss.hasPermi('content:record:export')")
    @Log(title = "个人修改企业记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EditRecord editRecord)
    {
        List<EditRecord> list = editRecordService.selectEditRecordList(editRecord);
        ExcelUtil<EditRecord> util = new ExcelUtil<EditRecord>(EditRecord.class);
        util.exportExcel(response, list, "个人修改企业记录数据");
    }
*/
    /**
     * 获取个人修改企业记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('content:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(editRecordService.selectEditRecordById(id));
    }

    /**
     * 新增个人修改企业记录
     */
    @PreAuthorize("@ss.hasPermi('content:record:add')")
    @Log(title = "个人修改企业记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EditRecord editRecord)
    {
        editRecord.setAsId(getUserId());
        return toAjax(editRecordService.insertEditRecord(editRecord));
    }

    /**
     * 修改个人修改企业记录
     */
    @PreAuthorize("@ss.hasPermi('content:record:edit')")
    @Log(title = "个人修改企业记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EditRecord editRecord)
    {
        return toAjax(editRecordService.updateEditRecord(editRecord));
    }

    /**
     * 删除个人修改企业记录
     */
    @PreAuthorize("@ss.hasPermi('content:record:remove')")
    @Log(title = "个人修改企业记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(editRecordService.deleteEditRecordByIds(ids));
    }
}
